import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/view/hello/world'

Vue.use(Router)

const routes = [
    {
        path: '/',
        name: 'HelloWorld',
        component: HelloWorld
    },
    { path: '*', redirect: '/' }
];
importPages(require.context('@/view', true, /\.vue$/,'lazy'))
function importPages (r) {
    r.keys().forEach(key => {
        routes.push({ path: (key.split('.'))[1], component: ()=>r(key)})
    });
}

export default new Router({
    routes: routes
})